<?
require_once("../config/dbconn.php");require_once("../config/usercls.php");require_once("../config/pagecls.php");require_once("pwd1cls.php");

$sqlhy="select * from {$db_prefix}users where id='".$_SESSION['sys_userid']."'";
$rshy=$db->get_one($sqlhy);

if($glo_closetx==1)  
{	echo "<script>alert('提现已经关闭\\n');location.href='announce_lst.php';</script>";
	exit();
}
if($act=='tixian'){
	$msg='';
	
	if(trim($bank)=='') $msg.="请选择汇入银行\\n";
	if(trim($bankaddress)=='') $msg.="请选择汇入银行地址\\n";
	//if(trim($bankno)=='') $msg.="请选择银行卡号\\n";
	//if(trim($bankname)=='') $msg.="请输入卡户名\\n";
	if(floatval($price)<=0) $msg.="请输入提现金额\\n";
	else{
		if(floatval($price)<$glo_tixianlower1) 
		{
			
				$msg.="提现金额最小是".$glo_tixianlower1."\\n";
				$tixianrate_real=$glo_tixianrate;
		}
		else{
			if ((floatval($price)%$glo_tixianlower)!=0){
				$msg.="提现金额必须是{$glo_tixianlower}的倍数\\n";
			}
			$tixianrate_real=$glo_tixianrate;
		}
	}
	if ($msg!=''){
		echo "<script>alert('$msg');history.back();</script>";exit();
	}
	if ($rshy['jjprice']<floatval($price)) $msg.="您没有足够的奖金币余额\\n";
	if ($msg!=''){
		echo "<script>alert('$msg');history.back();</script>";exit();
	}
	$feiyong=0;
	$feiyong=floatval($price)*$tixianrate_real/100;
	
	//扣款。提现
	$sqlkk="update {$db_prefix}users set jjprice=jjprice-'".floatval($price)."' where id='".$_SESSION['sys_userid']."'";
	$db->query($sqlkk);
	//财务记录
	$e_userid=$_SESSION['sys_userid'];$e_price=-floatval($price);$e_type=4;$e_ptype=3;$e_addtime=$curtime;$e_memo="奖金币提现";
	hyepricejl($e_userid,$e_price,$e_type,$e_ptype,$e_addtime,$e_memo);
	//插入数据库
	$dataArray['bank']=$bank;
	$dataArray['bankaddress']=$bankaddress;
	$dataArray['bankname']=$bankname;
	$dataArray['bankno']=$bankno;
	$dataArray['username']=$_SESSION['sys_username'];
	$dataArray['price']=floatval($price);
	$dataArray['feiyong']=$feiyong;
	$dataArray['state']=0;
	$dataArray['memo']=addslashes($memo);
	$dataArray['addtime']=$curtime;
	$dataArray['edittime']=0;
	$db->insert("{$db_prefix}tixian",$dataArray);
	
	echo "<script>alert(' 奖金币提现已提交');location.href='tixian_lst.php';</script>";exit();
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-image: url(image1/bg-body.png);
}
td{
font-size:12px;
}
.red{
	color:#FF0000
}
-->
</style>

<link href="images/skin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" height="29" valign="top" background="images/navbg1.png"><img src="images/left-top-right1.png" width="17" height="29" /></td>
    <td width="935" height="29" valign="top" background="images/navbg1.png"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">&nbsp;&nbsp;奖金提现记录</div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" background="images/navbg1.png"><img src="images/nav-right-bg.png" width="16" height="29" /></td>
  </tr>
  <tr>
    <td height="71" valign="middle" background="images/mail_leftbg1.png">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9"><table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="13" valign="top">&nbsp;</td>
      </tr>
      <tr>
        <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="nowtable">
                <tr>
                  <td class="left_bt2"><form id="form1" name="form1" method="post" action="?act=tixian">
                    <table width="100%" border="0"  cellpadding="3" cellspacing="1" bgcolor="#F7F8F9">
					<tbody bgcolor="#FFFFFF">
                      <tr>
                        <td colspan="3"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="nowtable">
                            <tr>
                              <td class="left_bt2">&nbsp;&nbsp;&nbsp;&nbsp;您的 奖金币余额：
                                  <?=$rshy['jjprice']?>
                                人民币/RMB. </td>
                            </tr>
                        </table></td>
                      </tr>
                      <tr>
                        <td height="30" colspan="3"><table width="100%" height="180" border="0">
						
                            <tr>
                              <td height="30" align="center" class="left_txt"><div align="center">汇入银行</div></td>
                              <td height="30" class="left_txt"><label>
                                <input name="bank" type="text" id="bank" value="<?=$rshy['bank']?>">
                                </label>
                              </td>
                            </tr>
                            <tr>
                              <td height="30" align="center" class="left_txt">银行开户地址</td>
                              <td height="30" class="left_txt"><label>
                                <input name="bankaddress" type="text" id="bankaddress" size="50" value="<?=$rshy['bankaddress']?>">
                              </label></td>
                            </tr>
                            <tr style="display:none">
                              <td height="30" align="center" class="left_txt">开户名</td>
                              <td height="30" class="left_txt"><label>
                                <input name="bankname" type="text" id="bankname" value="<?=$rshy['bankname']?>">
                              </label></td>
                            </tr>
                            <tr>
                              <td height="30" align="center" class="left_txt">卡号</td>
                              <td height="30" class="left_txt"><label>
                                <input name="bankno" type="hidden" id="bankno" size="40" value="<?=$rshy['bankno']?>">
                                ******
                                <?=substr($bankno,-4)?>
                              </label></td>
                            </tr>
                            <tr>
                              <td height="30" align="center" class="left_txt">金额</td>
                              <td height="30" class="left_txt"><label>
                                <input name="price" type="text" id="price" size="10" value="<?=$rs['price']?>">
                                人民币/RMB. ￥ <span class="red">*
                                  <? if ($glo_tixianlower1>0) {?>
                                  最低提现金额：
                                  <?=$glo_tixianlower1?>
                                  人民币/RMB. ￥
								  且是<?=$glo_tixianlower?>的倍数，
                                  <? }?>
                                  <? if ($glo_tixianrate1>0) {?>
                                  提现手续费：
                                  <?=$glo_tixianrate?>
                                  %
                                  <? }?>
                                </span></label></td>
                            </tr>
                            <tr>
                              <td height="30" align="center" class="left_txt">说明</td>
                              <td height="30" class="left_txt"><label>
                                <textarea name="memo" cols="40" rows="6" id="memo"><?=stripslashes($rs['memo'])?> </textarea>
                              </label></td>
                            </tr>
							
                        </table></td>
                      </tr>
                      <tr>
                        <td height="30" colspan="3">&nbsp;</td>
                      </tr>
                      <tr>
                        <td width="50%" height="30" align="right"><input name="id" type="hidden" id="id" value="<?=$id?>">
                            <input name="pageno" type="hidden" id="pageno" value="<?=$pageno?>">
                            <input type="submit" value="确定提现" name="B1" /></td>
                        <td width="6%" height="30" align="right">&nbsp;</td>
                        <td width="44%" height="30"><input type="reset" value="取消/Cancel" name="B12" /></td>
                      </tr>
                      <tr>
                        <td height="30" colspan="3">&nbsp;</td>
                      </tr>
					 </tbody>
                    </table>
                  </form></td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td height="30">提现记录
                <table width="100%" height="60" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                  <td height="30" align="center" bgcolor="#f2f2f2" >编号</td>
                  <td align="center" bgcolor="#f2f2f2" >银行</td>
                  <td align="center" bgcolor="#f2f2f2" >银行地址</td>
                  <td align="center" bgcolor="#f2f2f2" >卡号</td>
                  <td align="center" bgcolor="#f2f2f2" >开户名</td>
                  <td align="center" bgcolor="#f2f2f2" >提现金额</td>
                  <td align="center" bgcolor="#f2f2f2" >手续费</td>
                  <td align="center" bgcolor="#f2f2f2" >实际金额</td>
                  <td align="center" bgcolor="#f2f2f2" >状态</td>
                  <td align="center" bgcolor="#f2f2f2" >申请时间</td>
                  <td align="center" bgcolor="#f2f2f2" >审核时间</td>
                  <td height="30" align="center" bgcolor="#f2f2f2" >操作</td>
                  </tr>
  <?
  $query='';
  if ($action=='query'){
  	
  }
  $sql="select count(id) as c  from {$db_prefix}tixian where username='".$_SESSION['sys_username']."'";
  if ($query!='') $sql.=$query;
  $rs=$db->get_one($sql);
  $page=new pagecls(20,intval($rs['c']));
  $sql="select * from {$db_prefix}tixian where username='".$_SESSION['sys_username']."'";
  if ($query!='') $sql.=$query;
  $sql.=" order by id desc limit {$page->pastnum},{$page->pagesize}";
  $result=$db->query($sql);
  while($rs=$db->fetch_array($result)){
  ?>
                <tr>
                  <td align="center"><?=$rs['id']?></td>
                  <td align="center"><?=$rs['bank']?>                      </td>
                  <td align="center" ><?=$rs['bankaddress']?></td>
                  <td align="center" ><?=$rs['bankno']?></td>
                  <td align="center" ><?=$rs['bankname']?></td>
                  <td align="center" ><?=$rs['price']?></td>
                  <td align="center" class="red" ><?=$rs['feiyong']?></td>
                  <td align="center" class="left_txt3" ><?=$rs['price']-$rs['feiyong']?></td>
                  <td align="center" class="left_txt3" ><? if ($rs['state']==0) echo "等待审核";elseif ($rs['state']==1) echo "提现成功";elseif($rs['state']==2) echo "提现失败";?></td>
                  <td align="center" ><?=date("Y-m-d H:i:s",$rs['addtime'])?></td>
                  <td align="center" ><? if ($rs['edittime']>0) echo date("Y-m-d H:i:s",$rs['edittime'])?></td>
                  <td height="30" align="center" >
				  <a href="tixian_view.php?id=<?=$rs['id']?>&pageno=<?=$page->pageno?>">查看</a>
				 </td>
                  </tr>
	<?
  }
  $db->free_result($result);
  ?>
            </table></td>
            </tr>
            
            <tr>
              <td height="30">&nbsp;</td>
            </tr>
            <tr>
              <td height="30" align="right">每页
                <?=$page->pagesize?>
                条 第
                <?=$page->pageno?>/<?=$page->pagenum?>
                页 共
                <?=$page->recnum?>                条  <a href='?<?=$page->url?>1'><img src="image1/first.gif" border="0"></a>   <a href='?<?=$page->url.($page->pageno-1)?>'><img src="image1/back.gif" border="0"></a>  <a href='?<?=$page->url.($page->pageno+1)?>'><img src="image1/next.gif" border="0"></a>   <a href='?<?=$page->url.$page->pagenum?>'><img src="image1/last.gif" border="0"></a></td>
              </tr>
            <tr>
              <td height="30">&nbsp;</td>
            </tr>
          </table></td>
      </tr>
    </table></td>
    <td background="images/mail_rightbg.png">&nbsp;</td>
  </tr>
  <tr>
    <td valign="middle" background="images/mail_leftbg.png"><img src="images/buttom_left2.png" width="17" height="17" /></td>
      <td height="17" valign="top" background="images/buttom_bgs.png"><img src="images/buttom_bgs.png" width="17" height="17" /></td>
    <td background="images/mail_rightbg.png"><img src="images/buttom_right2.png" width="16" height="17" /></td>
  </tr>
</table>

</body>
</html>
